home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 101-125 / scopedisk122 / popup / source / checkitemsize < prev    next >
Text File  |  1995-03-19  |  4KB  |  155 lines

  1.            INCLUDE      "exec/types.i"
  2.            INCLUDE      "graphics/rastport.i"
  3.            INCLUDE      "graphics/text.i"
  4.            INCLUDE      "intuition/intuition.i"
  5.            INCLUDE      "PopUpMenu.i"
  6.  
  7.            xdef      @CheckItemSize
  8.  
  9.            xref      @Mystrlen
  10.  
  11. _LVOIntuiTextLength EQU   -$14a
  12. _LVOTextLength        EQU   -$36
  13.  
  14.            section      text,code
  15. *********************************************************
  16. * CheckItemSize(SizeSoFar,Item,Contents) -              *
  17. *  find the size needed to include Item in window.    *
  18. *                            *
  19. * Input:                        *
  20. *   SizeSoFar (A0)  Current size of window.             *
  21. *   Item      (A1)  Item to check.                      *
  22. *   Contents  (D0)  What to fill (ItemFill/SelectFill). *
  23. * Output:                        *
  24. *   SizeSoFar        New size of window            *
  25. *********************************************************
  26. @CheckItemSize:
  27.            MOVEM.L      D2-D7/A2-A3/A5-A6,-(SP)
  28.  
  29.            MOVEA.L      A0,A3           * A3 = SizeSoFar
  30.            MOVEA.L      A1,A2           * A2 = Item to check
  31.            MOVEA.L      D0,A5           * D0 = What to check
  32.  
  33. * ------------ Anything to check ?
  34. Check:           MOVE.L      A5,D0
  35.            BEQ.W      Done
  36.  
  37.            MOVE.W      mi_LeftEdge(A2),D3  * D3 = LeftEdge
  38.            MOVE.W      mi_TopEdge(A2),D2   * D2 = TopEdge
  39.            MOVE.W      D3,D7           * D7 = Left
  40.            MOVE.W      D2,D6           * D6 = Top
  41.            MOVE.W      D3,D5
  42.            MOVE.W      D2,D4
  43.  
  44. * ------------ ITEMTEXT or ITEMIMAGE ?
  45.            MOVEQ.L      #ITEMTEXT,D0
  46.            AND.W      mi_Flags(A2),D0
  47.            BEQ.B      ItemImage
  48.  
  49. * ------------ Add IText position to left and top.
  50.            ADD.W      it_LeftEdge(A5),D7
  51.            ADD.W      it_TopEdge(A5),D6
  52.  
  53. * ------------ What font to use ?
  54.            TST.L      it_ITextFont(A5)
  55.            BEQ.B      DefaultFont
  56.  
  57. * ------------ Find length of string in pixels.
  58.            MOVEA.L      A5,A0
  59.            MOVEA.L      _IntuitionBase(A4),A6
  60.            JSR      _LVOIntuiTextLength(A6)
  61.  
  62. * ------------ Add to LeftEdge.
  63.            ADD.W      D0,D5           * D5 = Right
  64.  
  65. * ------------ Find hight of string in pixels and add to top.
  66.            MOVEA.L      it_ITextFont(A5),A1
  67.            ADD.W      ta_YSize(A1),D4     * D4 = Bottom
  68.            BRA.B      NextText
  69.  
  70. * ------------ Find length of string with default font.
  71. DefaultFont:   MOVEA.L      it_IText(A5),A0
  72.            JSR      @Mystrlen(PC)
  73.            LEA      _Rp(A4),A1
  74.            MOVEA.L      it_IText(A5),A0
  75.            MOVEA.L      _GfxBase(A4),A6
  76.            JSR      _LVOTextLength(A6)
  77.  
  78. * ------------ Add to LeftEdge to get rightedge.
  79.            ADD.W      D0,D5
  80.  
  81. * ------------ Find hight of string in pixels and add to top to get bottom.
  82.            MOVE.W      _Rp+rp_TxHeight(A4),D4
  83.            ADD.W      D6,D4
  84.  
  85. * ------------ Move to next text.
  86. NextText:      MOVEA.L      it_NextText(A5),A5
  87.            BRA.B      CheckLeft
  88.  
  89. * ------------ Add Image position to left and top.
  90. ItemImage:     ADD.W      (A5),D7
  91.            ADD.W      ig_TopEdge(A5),D6
  92.  
  93. * ------------ Add Imgage width and height to right and bottom.
  94.            ADD.W      ig_Width(A5),D5
  95.            ADD.W      ig_Height(A5),D4
  96.  
  97. * ------------ Move to next image
  98.            MOVE.L      ig_NextImage(A5),A5
  99.  
  100. * ------------ Find lowest leftedge.
  101. CheckLeft:     CMP.W      D7,D3           * D3 = LeftEdge
  102.            BGE.B      1$
  103.            MOVE.L      D3,D7
  104. 1$:           CMP.W      (A3),D7
  105.            BGE.B      CheckRight
  106.            MOVE.W      D7,(A3)
  107.  
  108. * ------------ Find Biggest RightEdge
  109. CheckRight:    ADD.W      mi_Width(A2),D3     * D3 = RightEdge
  110.            CMP.W      D5,D3
  111.            BLE.B      1$
  112.            MOVE.L      D3,D5
  113. * ------------ If item has subitem make room for pointer.
  114. 1$:           TST.L      mi_SubItem(A2)
  115.            BEQ.B      2$
  116.            ADDQ.W      #6,D5
  117. * ------------ If screentype is HIRESSCREEN make pointer bigger.
  118.            TST.W      _ScreenType(A4)
  119.            BNE.B      2$
  120.            ADDQ.W      #4,D5
  121. 2$:           CMP.W      ws_Right(A3),D5
  122.            BLE.B      CheckTop
  123.            MOVE.W      D5,ws_Right(A3)
  124.  
  125. * ------------ Find lowest Topedge.
  126. CheckTop:      CMP.W      D6,D2           * D2 = TopEdge
  127.            BGE.B      1$
  128.            MOVE.L      D2,D6
  129. 1$:           CMP.W      ws_Top(A3),D6
  130.            BGE.B      CheckBottom
  131.            MOVE.W      D6,ws_Top(A3)
  132.  
  133. * ------------ Find biggest bottompos.
  134. CheckBottom:   ADD.W      mi_Height(A2),D2    * D2 = BottomEdge
  135.            CMP.W      D4,D2
  136.            BLE.B      1$
  137.            MOVE.L      D2,D4
  138. 1$:           CMP.W      ws_Bottom(A3),D4
  139.            BLE.B      2$              * Size comes before speed.
  140.            MOVE.W      D4,ws_Bottom(A3)
  141. 2$           BRA.W      Check
  142.  
  143. Done:           MOVEM.L      (SP)+,D2-D7/A2-A3/A5-A6
  144.            RTS
  145.  
  146.            section      __MERGED,bss
  147.  
  148.            xref      _Rp
  149.            xref      _ScreenType
  150.            xref      _IntuitionBase
  151.            xref      _GfxBase
  152.  
  153.            END
  154.  
  155.